<?php

namespace backend\modules\admin\controllers;

use common\helper\ResponseHelper;
use mdm\admin\components\MenuHelper;
use yii\web\Controller;

class DefaultController extends Controller
{
    public function actionIndex()
    {
        return $this->render('index');
    }

    public function actionSearch($uid) {
        $callback = function ($menu) {
            $data = eval($menu['data']);
            return [
                'id' => $menu['id'],
                'name' => $menu['name'],
                'icon' => $menu['icon'],
                'url' => $menu['route'],
                'pid' => $menu['parent'],
                'options' => $data,
                'children' => $menu['children']
            ];
        };
        return ResponseHelper::success(MenuHelper::getAssignedMenu($uid,100000,$callback,true));

    }
}
